import { Button } from 'antd';
import { $Between, $Input, $Select, $InputNumber } from '@/.jiess';
export default {
	name: 'DemoForm',
	isJiess: true,
	setup() {
		const area = this.area({
			title: '用户信息',
			extra: this.render({
				is: Button,
				size: 'small',
				type: 'primary',
				onClick: async () => {
					const values = await action.value()
					alert(JSON.stringify(values));
				}
			}, '查看用户信息').getNative()
		});

		const action = area.add(
			$Input({
				$name: 'name',
				$label: '姓名',
				$rules: ['required', [2, 4]]
			}),
			$Select({
				$name: 'sex',
				$label: '性别',
				$options: [
					{ text: '男', value: 1 },
					{ text: '女', value: 2 }
				],
				$rules: ['required']
			}),
			$InputNumber({
				$name: 'age',
				$label: '年龄',
				$rules: [val => {
					if (val < 18) return '您还是未成年！！';
				}]
			})
		).done();
	}
}